Skip to content

[WIP] poc: branch-associated Chat Sessions#267139

Closed
rwoll wants to merge 8 commits intomicrosoft:mainfrom
rwoll:self-hosting-auto-chat-tracking
Closed

[WIP] poc: branch-associated Chat Sessions#267139
rwoll wants to merge 8 commits intomicrosoft:mainfrom
rwoll:self-hosting-auto-chat-tracking

Conversation

@rwoll
Copy link
Member

@rwoll rwoll commented Sep 17, 2025

No description provided.

Copy link
Member Author

@rwoll rwoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First working draft. Some higher level followups:

  • when switching chat sessions, auto checkout the branch as well.
  • UI treatment - when you checkout out a previous branch, it's not obvious the chat session is restored since before v. after is a wall of text. Need some UI indicator.
  • Put this all behind a setting.

{
label: i.title,
description: i.isActive ? `(${localize('currentChatLabel', 'current')})` : '',
description: i.isActive ? `(${i.createdOnBranch} - ${localize('currentChatLabel', 'current')})` : `${i.createdOnBranch}`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use last active branch instead of createdOnBranch?

if (suggestCtrl) {
const curText = widget.inputEditor.getValue();
const newValue = curText ? `@ ${curText}` : '@';
const newValue = curText ? `@${curText}` : '@';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert. this seems unrelated.

override async run(accessor: ServicesAccessor): Promise<void> {
const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
extensionsWorkbenchService.openSearch(`@feature:${CopilotUsageExtensionFeatureId}`);
extensionsWorkbenchService.openSearch(`@feature: ${CopilotUsageExtensionFeatureId}`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert. unrelated.

export const ACTION_ID_NEW_CHAT = `workbench.action.chat.newChat`;
export const ACTION_ID_NEW_EDIT_SESSION = `workbench.action.chat.newEditSession`;
export const CHAT_OPEN_ACTION_ID = 'workbench.action.chat.open';
export const CHAT_OPEN_HISTORICAL_SESSION_ACTION_ID = 'workbench.action.chat.openHistoricalSession';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const CHAT_OPEN_HISTORICAL_SESSION_ACTION_ID = 'workbench.action.chat.openHistoricalSession';
export const CHAT_RESTORE_SESSION_ACTION_ID = 'workbench.action.chat.restoreSession';

// Set up listener for current history item ref changes (HEAD movement)
return runOnChange(historyProvider.historyItemRef, () => {
// Fire event when the current branch reference changes
const currentBranch = this.getCurrentBranch();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use getCurrentBranch()…or does historyItemRef have the actual branch info already?

return runOnChange(historyProvider.historyItemRef, () => {
// Fire event when the current branch reference changes
const currentBranch = this.getCurrentBranch();
this._onChangedBranch.fire(currentBranch);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to debounce this?

this._register(this.gitStatus.onChangedBranch(async branch => {
console.log('Branch changed to:', branch);
const history = await this.getHistory();
const sessionId = history.find(h => h.lastUsedOnBranch === branch)?.sessionId;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check ordering on this. Ensure history is sorted in an expected way. Ideally, we want the most recent session related to the branch.

@rwoll rwoll closed this Sep 17, 2025
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Nov 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant